<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import=" com.google.appengine.api.datastore.Entity" %>
<%@ page import="info.niwota.gae.cache.BlobObject" %>
<%@ page import="info.niwota.gae.cache.DataStoreUtils" %>
<%@ page import="java.util.List" %>
<%
  User user = (User) request.getAttribute("user");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Cache Store</title>
  </head>
  <body>
    <div align="right">

    </div>


    <h1 align="center">

       Cache Store
 
    </h1>

    <hr>
      <%
         List<Entity> files =
           (List<Entity>) request.getAttribute("files");
         if (files.size() > 0) {
           for (int i = 0; i < files.size(); i++) {
             BlobObject item = DataStoreUtils.toBlobObject(files.get(i));
      %>
            <b>
              <% if (item.isImage()) { %>
                <a href="/cache/view?key=<%=item.getBlob() %>">
              <% } else { %>
                <a href="/cache/download?key=<%=item.getBlob() %>">
              <% } %>
               <%=item.getName()%>
            	</a>
            </b>:
            <%=item.getKey()%>,
            <%=item.getOwner()%>,
            <%=item.getBlob()%>,
            <%=item.getPeer()%>,
            <%=item.getName()%>, 
            <%=item.getUri()%>,
            <%=item.getSize()%>,
            <%=item.getType()%>,
            <%=item.getModified()%>,
            <%=item.getCreation()%>,
            <%=item.getAccess()%>,
            <%=item.getCount()%> 
            <a href="/cache/delete?key=<%=item.getBlob() %>">Delete</a>
            <br />
   
      <%
           }
         } else {
      %>
        <div align="center">
          Empty
        </div>
      <% } %>


      <hr />
      <a href="/cache/upload">Upload</a>
    
  </body>
</html>
